import {
    getManegelist,
    getCompanyManegelist
} from '@/services/myRecruit/candidate';

export default {
    namespace: 'manage',
    state: {
        manageList: [],
        pagination: {
            current: 1,
            pageSize: 10,
            total: 0
        },
        orderBy: '',
        candidateStage: [], // 筛选阶段
        candidateState: [] // 筛选状态
    },
    effects: {
        // 我管理的候选人列表
        *fetchManageList({ payload }, { call, put }) {
            const result = yield call(getManegelist, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        manageList: result.data.rows,
                        pagination: {
                            pageSize: result.data.pageSize,
                            current: result.data.pageNo,
                            total: result.data.total
                        }
                    }
                });
            }
        },
        // 企业管理-勾选人管理列表
        *fetchCompanyManageList({ payload }, { call, put }) {
            const result = yield call(getCompanyManegelist, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        manageList: result.data.rows,
                        pagination: {
                            pageSize: result.data.pageSize,
                            current: result.data.pageNo,
                            total: result.data.total
                        }
                    }
                });
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
